home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / netprog.zip / NETPROG.TAR / ping / finish.c < prev    next >
C/C++ Source or Header  |  1989-12-17  |  613b  |  24 lines

  1. /*
  2.  * Print out statistics, and stop.
  3.  * We're called both when a SIGINT signal is received, or if the
  4.  * specified number of packets have been received.
  5.  */
  6.  
  7. #include    "defs.h"
  8.  
  9. sig_finish()
  10. {
  11.     printf("\n----%s PING Statistics----\n", hostname );
  12.     printf("%d packets transmitted, ", ntransmitted );
  13.     printf("%d packets received, ", nreceived );
  14.     if (ntransmitted)
  15.         printf("%d%% packet loss",
  16.             (int) (((ntransmitted-nreceived)*100) / ntransmitted) );
  17.     printf("\n");
  18.     if (nreceived && timing)
  19.         printf("round-trip (ms)  min/avg/max = %d/%d/%d\n",
  20.                 tmin, tsum / nreceived, tmax );
  21.     fflush(stdout);
  22.     exit(0);
  23. }
  24.